﻿using System;
using OOXMLGenerator.Enums;

namespace OOXMLGenerator.DataStructure
{
    /// <summary>
    /// Is a custom Section Content with PartContentType.Documents Type
    /// </summary>
    public class DocSectionContent : SectionContent
    {
        /// <summary>
        /// Empty constructors - initializes a new instance of the DocSectionContent Class.
        /// Properties settings:
        /// Header = Properties.Resources.Header_Documents;
        /// Type = PartContentType.Documents        
        /// Content = new instance of PartDataSet.PartDocumentsDataTable
        /// </summary>
        public DocSectionContent()
        {
            base.Header = Properties.Resources.Header_Documents;
            base.Type = PartContentType.Documents;
            base.Content = new PartDataSet.PartDocumentsDataTable();
        }

        /// <summary>
        /// Initializes a new instance of the DocSectionContent Class.
        /// Properties settings:
        /// Header = header
        /// Type = PartContentType.Documents        
        /// Content = new instance of PartDataSet.PartDocumentsDataTable
        /// </summary>
        /// <param name="header">Document Section Content header</param>
        public DocSectionContent(string header)
        {
            base.Header = header;
            base.Type = PartContentType.Documents;
            base.Content = new PartDataSet.PartDocumentsDataTable();
        }

        /// <summary>
        /// Adds a row to Document Section Content initialized with given parameters.
        /// </summary>
        /// <param name="sequence">sort order</param>
        /// <param name="name">document name</param>
        /// <param name="revision">last revision</param>
        public void AddDOCItem(int? sequence, string name, string revision)
        {
            PartDataSet.PartDocumentsRow docRow = ((PartDataSet.PartDocumentsDataTable)base.Content).NewPartDocumentsRow();
            if (sequence != null)
                docRow.sort_order = (int)sequence;
            docRow.related_id = name;
            docRow.major_rev = revision;
            ((PartDataSet.PartDocumentsDataTable)base.Content).AddPartDocumentsRow(docRow);
        }
    }
}
